package com.godofgamblers.hotelmanagementsystem.mapper;

import com.godofgamblers.hotelmanagementsystem.dto.OrderItemDTO;
import com.godofgamblers.hotelmanagementsystem.pojo.CheckInfo;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/*

@author huanglang

@create_time 2019-10-15 14:17

Nothing is difficult but bugs

*/
@Repository
public interface CheckInInfoMapper {

    @Select("SELECT COUNT(*) AS room_count\n" +
            "FROM check_in_info cii,order_item oi,room_type rt\n" +
            "WHERE cii.order_item_id=oi.order_item_id AND rt.room_type_id=oi.room_type_id AND cii.check_in_time LIKE #{today}\n" +
            "GROUP BY rt.room_type_id")
    public List<Integer> getRoomsDataByTime(String today);

    @Select("SELECT cii.room_num,actual_name,id_card,check_in_time,check_out_time,room_type_name\n" +
            "FROM check_in_info cii,room r,room_type rt\n" +
            "WHERE cii.room_num=r.room_num AND r.room_type_id=rt.room_type_id AND id_card=#{context}")
    public List<CheckInfo> getCheckInfoByIdCard(String context);

    @Select("SELECT cii.room_num,actual_name,id_card,check_in_time,check_out_time,room_type_name\n" +
            "FROM check_in_info cii,room r,room_type rt\n" +
            "WHERE cii.room_num=r.room_num AND r.room_type_id=rt.room_type_id AND cii.room_num=#{context}")
    public List<CheckInfo> getCheckInfoByRoomNum(String context);

    @Select("SELECT cii.room_num,actual_name,id_card,check_in_time,check_out_time,room_type_name\n" +
            "FROM check_in_info cii,room r,room_type rt\n" +
            "WHERE cii.room_num=r.room_num AND r.room_type_id=rt.room_type_id AND actual_name=#{context}")
    public List<CheckInfo> getCheckInfoByName(String context);

    @Select("SELECT cii.room_num,actual_name,id_card,check_in_time,check_out_time,room_type_name\n" +
            "FROM check_in_info cii,room r,room_type rt\n" +
            "WHERE cii.room_num=r.room_num AND r.room_type_id=rt.room_type_id AND check_in_time LIKE #{day}")
    public List<CheckInfo> getCheckInfoByDay(String day);


}
